# $Id: PKGBUILD 1395 2009-08-18 19:14:37Z ibiru $
# Maintainer: Jason Chu <jason@archlinux.org>

pkgname=jre
pkgver=5.0u21
pkgrel=1
pkgdesc="Sun's java runtime environment"
#arch=('i686' 'x86_64')
arch=('i686')
  [ "$CARCH" = "i686" ]   && _arch=i586
  #[ "$CARCH" = "x86_64" ] && _arch=amd64
url="http://java.sun.com"
depends=('glibc' 'libxtst')
install="jre.install"
source=(http://download.java.net/dlj/binaries/jdk-$pkgver-dlj-linux-$_arch.bin
        https://jdk-distros.dev.java.net/source/browse/*checkout*/jdk-distros/trunk/utils/construct.sh
        jre.profile)
[ "$CARCH" = "i686" ]   && md5sums=('36f1628264efaaebf70812cdafb27a52'
         			    '94065b612df0046d9ae758943f9f6a75'
	          		    '50b4f5ac4129097461d246645d73a622')
#[ "$CARCH" = "x86_64" ] && md5sums=('92c45c9304ac3bc3103883f61b1f49df'
         			    #'94065b612df0046d9ae758943f9f6a75'
			            #'50b4f5ac4129097461d246645d73a622')
replaces=('j2re')
conflicts=('j2re' 'java-runtime')
provides=('j2re' 'java-runtime=6')
license=('custom')

build() {
  cd $startdir/src

  mkdir unbundle-jdk
  cd unbundle-jdk

  sh ../jdk-$pkgver-dlj-linux-$_arch.bin --accept-license

  cd ..

  sh construct.sh unbundle-jdk linux-jdk linux-jre

  mkdir -p $startdir/pkg/opt/java
  mv linux-jdk/jre $startdir/pkg/opt/java

  install -D -m755 $startdir/src/${pkgname}.profile $startdir/pkg/etc/profile.d/${pkgname}.sh

  mkdir -p $startdir/pkg/usr/lib/mozilla/plugins

  if [ "$CARCH" = "i686" ]; then
    ln -s /opt/java/jre/lib/i386/libnpjp2.so $startdir/pkg/usr/lib/mozilla/plugins
    else ln -s /opt/java/jre/lib/amd64/libnpjp2.so $startdir/pkg/usr/lib/mozilla/plugins
  fi

  mkdir -p $startdir/pkg/usr/share/licenses/jre
  cp $startdir/pkg/opt/java/jre/COPYRIGHT $startdir/pkg/usr/share/licenses/jre
  cp $startdir/pkg/opt/java/jre/LICENSE $startdir/pkg/usr/share/licenses/jre
  cp $startdir/pkg/opt/java/jre/THIRDPARTYLICENSEREADME.txt $startdir/pkg/usr/share/licenses/jre
}
